package com.atguigu.guli.service.vod.controller.admin;

import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.vod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/vod")

public class AdminVodController {
    @Autowired
    VodService vodService;

    //上传视频
    @PostMapping("/upload")
    public R upload(MultipartFile video){
        //上传成功后返回一个视频的id
        String videoId = vodService.upload(video);
        return R.ok().data("id",videoId);
    }

    //获取播放视频凭证
    @GetMapping("/getPlayAuth/{videoId}")
    public R getPlayAuth(@PathVariable("videoId")String videoId){
        String playAuth = vodService.getPlayAuth(videoId);
        return R.ok().data("palyAuth",playAuth);
    }
}
